package com.api.oa.services.impl;

import cn.hutool.core.date.DateUtil;
import com.api.oa.mapper.YQFeedBackMapper;
import com.api.oa.model.entity.YQFeedBack;
import com.api.oa.services.YQFeedBackService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class YQFeedBackServiceImpl implements YQFeedBackService {

    @Autowired
    private YQFeedBackMapper mapper;


    @Override
    public Integer add(YQFeedBack entity) {
        entity.setCreatedAt(DateUtil.date());
        return mapper.insert(entity);
    }

    @Override
    public void remove(Long id) {
        mapper.delete(id);
    }

    @Override
    public Integer update(YQFeedBack entity) {
        return mapper.update(entity);
    }

    @Override
    public PageInfo<YQFeedBack> list(String keyWord,Integer pageIndex,Integer pageSize) {
        PageHelper.startPage(pageIndex,pageSize);
        PageHelper.orderBy("feedbackId desc");
        return new PageInfo<>(mapper.list(keyWord));
    }

    @Override
    public YQFeedBack one(Long id) {
     return mapper.findOne(id);
    }



}
